package com.sinothk.androidx.views;

import android.view.View;

import com.sinothk.android.views.TitleBarView;
import com.sinothk.androidx.R;

public class TitleBaseActivity extends BaseActivity {
    protected TitleBarView titleBarView;

    public void setLeftViewGone() {
        titleBarView = this.findViewById(R.id.titleBarView);
        titleBarView.setLeftVisible(View.INVISIBLE);
    }

    public void setViewTitle(String centerTxt) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
    }

    public void setViewTitle(String centerTxt, String subTitleTxt) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterSubTxt(subTitleTxt);
    }

    public void setViewTitle(String centerTxt, int imgResId, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);

        titleBarView.setRight1Icon(imgResId, clickListener);
    }

    public void setViewTitle(String centerTxt, String rightTxt, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);

        titleBarView.setRight1Txt(rightTxt, clickListener);
    }

    public void setViewTitle(String centerTxt, String subTitleTxt, String rightTxt, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterSubTxt(subTitleTxt);

        titleBarView.setRight1Txt(rightTxt, clickListener);
    }

    public void setViewTitle(String centerTxt, String subTitleTxt, int rightIcon, View.OnClickListener clickListener) {
        titleBarView = this.findViewById(R.id.titleBarView);

        titleBarView.setLeftIcon(R.drawable.back_icon);
        titleBarView.setLeftVisible(View.VISIBLE);
        titleBarView.setLeftViewClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        titleBarView.setCenterTxt(centerTxt);
        titleBarView.setCenterSubTxt(subTitleTxt);

        titleBarView.setRight1Icon(rightIcon, clickListener);
    }
}
